<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>司机管理</title>
    <meta name="decorator" content="default"/>
    <link href="${ctxStatic}/static_back/css/public.css" type="text/css" rel="stylesheet">
    <link href="${ctxStatic}/static_back/css/main.css" type="text/css" rel="stylesheet">
</head>

<body>
<%--标题--%>
<div class="top-section">
    <h2>司机管理</h2>
</div>

<div class="body-section white-body">
    <%--功能区--%>
    <form:form id="searchForm" modelAttribute="airDriver" action="${ctx}/air/airDriver/" method="post">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
        <div class="function-box">
            <div class="left-function">
                <form:input path="name" htmlEscape="false" class="function-ipt" placeholder="输入姓名查询"/>
                <form:select path="airCar.servicePointName" htmlEscape="false">
                    <form:option value="" label="全部服务站点"/>
                    <form:options items="${rides}" itemValue="name" itemLabel="name"/>
                </form:select>
                <input id="btnSubmit" class="btn btn-main" type="submit" value="查询"/>
            </div>
            <div class="right-function">
                <shiro:hasPermission name="air:airDriver:edit">
                    <a href="${ctx}/air/airDriver/form" class="btn btn-blue">新增司机</a>
                </shiro:hasPermission>
            </div>
        </div>
    </form:form>
    <sys:message content="${message}"/>

    <%--表格区--%>
    <div class="table-box">
        <table id="contentTable">
            <thead>
            <tr>
                <th colspan="4" class="td-bb td-rb">基本信息</th>
                <th colspan="3" class="td-bb td-rb">配置信息</th>
                <shiro:hasPermission name="air:airDriver:edit">
                    <th rowspan="2" width="14%">操作</th>
                </shiro:hasPermission>
            </tr>
            <tr>
                <th width="8%">姓名</th>
                <th width="18%">身份证</th>
                <th width="12%">联系电话</th>
                <th width="10%" class="td-rb">对讲机</th>
                <th width="12%">驾驶车辆</th>
                <th width="8%">类型</th>
                <th width="18%" class="td-rb">服务站点</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${page.list}" var="airDriver">
                <tr>
                    <td>
                        <a href="javascript:void(0)" class="details" data-id="${airDriver.id}">
                                ${airDriver.name}
                        </a>
                    </td>
                    <td>
                            ${airDriver.idNumber}
                    </td>
                    <td>
                            ${airDriver.phone}
                    </td>
                    <td class="td-rb">
                            ${airDriver.interphone}
                    </td>
                    <td>
                            ${airDriver.airCar.carNumber}
                    </td>
                    <td>
                            ${airDriver.airCar.type}
                    </td>
                    <td class="td-rb">
                            ${airDriver.airCar.airRidePoint.name}
                    </td>
                    <td class="td-center">
                        <shiro:hasPermission name="air:airDriver:edit">
                            <a href="javascript:void(0)" class="details font-link" data-id="${airDriver.id}">详情</a>
                            <a href="${ctx}/air/airDriver/form?id=${airDriver.id}" class="font-link">修改</a>
                            <a href="${ctx}/air/airDriver/delete?id=${airDriver.id}"
                               onclick="return confirmx('确认要删除该司机吗？', this.href)" class="font-link">删除</a>
                        </shiro:hasPermission>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
        <div class="pagination table-pagination">${page}</div>
    </div>
</div>

<%--详情弹窗--%>
<div id="detailDiv" class="window-layer window-details">
    <div class="window-bg"></div>
    <div class="window-main">
        <div class="window-body">

            <%--主要信息--%>
            <div class="details-div">
                <h3 id="driverName"></h3>
                <div class="info-box">
                    <ul class="info-list">
                        <li class="info-icon-id" title="身份证">
                            <span id="dr_idnumber"></span>
                        </li>
                        <li class="info-icon-building" title="所属公司">
                            <span id="dr_belong"></span>
                        </li>
                        <li class="info-icon-phone" title="联系电话">
                            <span id="dr_phone"></span>
                        </li>
                        <li class="info-icon-talk" title="对讲机">
                            <span id="dr_interphone"></span>
                        </li>
                    </ul>
                </div>
                <div class="info-box">
                    <h4>车辆信息</h4>
                    <ul class="info-list">
                        <li class="info-icon-car" title="车辆信息">
                            <span id="car_carnumber"></span>&nbsp&nbsp
                            <span id="car_seating"></span>&nbsp&nbsp
                            <span id="car_type"></span>
                        </li>
                    </ul>
                </div>
                <div class="info-box">
                    <h4>行程信息</h4>
                    <ul class="info-list">
                        <li class="info-icon-start" title="行程起点">
                            <span id="dr_startpointName"></span>
                        </li>
                        <li class="info-icon-end" title="行程终点">
                            <span id="dr_tarplace"></span>
                        </li>
                    </ul>
                </div>
                <div class="info-box">
                    <h4>服务站点信息</h4>
                    <ul class="info-list">
                        <li class="info-icon-home" title="乘车点">
                            <span id="rp_pointName"></span>
                        </li>
                        <li class="info-icon-person" title="乘车点负责人">
                            <span id="rp_leader"></span>&nbsp&nbsp
                            <span id="rp_phone"></span>
                        </li>
                        <li class="info-icon-position" title="乘车点位置">
                            <span id="rp_position"></span>
                        </li>
                    </ul>
                </div>
                <div class="window-bottom">
                    <input type="button" class="btn" value="关闭" onclick="CloseDiv()"/>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    $(function () {
        $(".details").click(function () {
            var driverId = $(this).data("id");
            $.ajax({
                url: "${ctx}/air/airDriver/getDriver",
                type: "GET",
                data: {driverId: driverId},
                success: function (data) {
                    var driver = data.data;
                    $("#driverName").html(driver.name);
                    $("#dr_idnumber").html(driver.idNumber);
                    $("#dr_belong").html(driver.belongUnit);
                    $("#dr_phone").html(driver.phone);
                    $("#dr_interphone").html(driver.interphone);
                    var car = data.data.airCar;
                    if (car !== null && typeof car !== 'undefined') {
                        $("#car_carnumber").html(car.carNumber);
                        $("#car_seating").html(car.seating);
                        $("#car_type").html(car.type);
                        var point = data.data.airCar.airRidePoint;
                        if (point !== null && typeof point !== 'undefined') {
                            $("#dr_startpointName").html(point.name);
                            $("#rp_pointName").html(point.name);
                            $("#rp_leader").html(point.leader);
                            $("#rp_position").html(point.position);
                            $("#rp_phone").html(point.phone);
                            var parking = point.airParkingLot;
                            if(parking!==null&& typeof parking !=='undefined') {
                                $("#dr_tarplace").html(parking.name);
                            }
                        }
                    }
                }
            });
            $("#detailDiv").css("display", "block");
        })
    });

    function page(n, s) {
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }

    function CloseDiv() {
        $("#detailDiv").css("display", "none");
    }
</script>
</body>
</html>